import taichi as ti

ti.init()

tensor_a = ti.field(dtype=ti.f32,shape=(10,10))
tensor_b = ti.field(dtype=ti.f32,shape=(10,10))

@ti.func
def some_function(a:ti.template()):
    return a+2

@ti.kernel
def my_kernel1():
    for i,j in tensor_a:
        tensor_b[i,j]=some_function(tensor_a[i,j])

@ti.kernel
def my_kernel2():
    a,b,fun = ti.static(tensor_a,tensor_b,some_function)
    for i,j in a:
        b[i,j]=fun(a[i,j])

my_kernel2()
print(tensor_b)